/**
 * 
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 *   
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 * 
 */
package star.trek.voyager.module.benz.car_sls_amg;

import org.jiopi.framework.annotation.module.Instantiation;
import org.jiopi.framework.annotation.module.RegisterModule;
import org.jiopi.framework.annotation.module.SocketModule;
import star.trek.voyager.blueprint.car.Car;
import star.trek.voyager.blueprint.engine.Engine;
import star.trek.voyager.blueprint.engine.StatusOutput;
import org.apache.log4j.Logger;

@Instantiation(initMethod="init")
@RegisterModule({
	"star.trek.voyager.blueprint.car.Car"
	})
public class BenzSlsAmg implements Car , StatusOutput{
	
	private static Logger logger = Logger.getLogger(BenzSlsAmg.class);
	
	
	
	private String engineStatus = null;
	
	@SocketModule(id="engine",module="voyager.benz.engine_v8",version="0.1.0.0")
	private Engine engine;
	
	public void init(){
		logger.info(toString()+" with "+engine);
	}

	public void start() {
		//System.out.println("Car start");
		engine.retrofire();
	}

	public void stop() {
		//System.out.println("Car stop");
		engine.flameout();
	}
	
	public String getStatus() {
		return "BenzSlsAmg Status : "+(engineStatus==null?"engine not start":engineStatus)+"\n"+engine.checkStatus()+"\n";
	}

	public void output(String status) {
		//System.out.println("Car output "+status);
		engineStatus = status;
		
	}
	
	//for pojo use
	public void setEngine(Engine engine){
		this.engine = engine;
	}
	
	@Override
	public String toString(){
		return this.getClass().getName()+"-0.1.0.0";
	}
}
